package com.jing.product.domain.enums;

/**
 * @Author：HaoYunde
 * @Package：com.jing.product.domain.enumeration
 * @Project：Jing
 * @name：PriceType
 * @Date：2024/6/4 15:28
 */

public enum PriceType {

    //枚举
    ORIGINAL_PRICE(0,"无促销"),
    PROMOTION_PRICE(1,"特惠促销"),
    MEMBER_PRICE(2,"会员价"),
    LADDER_PRICE(3,"阶梯价格"),
    FULL_REDUCTION_PRICE(4,"满减价格");



    private Integer code;
    private String name;


    PriceType(Integer code, String name) {
        this.code = code;
        this.name = name;
    }


    public Integer getCode() {
        return code;
    }


    public String getName() {
        return name;
    }






    public static  PriceType getEnumByCode(Integer code){
        if (code == null){
            return ORIGINAL_PRICE;
        }
        PriceType[] values = PriceType.values();
        for (int i = 0; i < values.length; i++) {
            if (values[i].code.equals(code)){
                return values[i];
            }
        }
        //默认返回enumByCode
        return ORIGINAL_PRICE;
    }


}
